//
//  DetailCollectionViewCell.m
//  Travel
//
//  Created by lanou on 15/9/21.
//  Copyright (c) 2015年 TeamThree. All rights reserved.
//

#import "DetailCollectionViewCell.h"
#define kAutoWidth 375 * kWidth
#define kAutoHight 667 * kHeight
@implementation DetailCollectionViewCell

- (void)dealloc
{
    [_title release];
    [_imgView release];
    [_viewCount release];
    [_likeCount release];
    [_picCount release];
    [_authorImgView release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        CGFloat width = self.bounds.size.width;
        CGFloat height = self.bounds.size.height;
        _imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, width, height)];
        //_imgView.backgroundColor = [UIColor colorWithRed:0.000 green:0.502 blue:1.000 alpha:1.000];
        [self addSubview:_imgView];
        
        UIImageView *coverImg = [[UIImageView alloc] initWithFrame:_imgView.bounds];
        coverImg.image = [UIImage imageNamed:@"phone_desc_tripcell_shadow"];
        [_imgView addSubview:coverImg];
        [coverImg release];
        
        _title = [[UILabel alloc] initWithFrame:CGRectMake(20.0 / kAutoWidth, 20.0 / kAutoWidth, width - 30.0 / kAutoWidth, 50.0 / kAutoHight)];
        //_title.backgroundColor = [UIColor blueColor];
        _title.text = @"冬季去喀纳斯看雪";
        _title.layer.shadowColor = [[UIColor blackColor] CGColor];
        _title.numberOfLines = 0;
        //[_title sizeToFit];
        _title.textColor = [UIColor whiteColor];
        _title.font = [UIFont boldSystemFontOfSize:18];
        [coverImg addSubview:_title];
        
        UIImageView *eyeImg = [[UIImageView alloc] initWithFrame:CGRectMake(20.0 / kAutoWidth, height - 20.0 / kAutoWidth, 14.0 / kAutoWidth, 14.0 / kAutoWidth)];
        eyeImg.image = [UIImage imageNamed:@"icon_view_trip"];
       // eyeImg.alpha = 0.7;
        [coverImg addSubview:eyeImg];
        [eyeImg release];
        
        _viewCount = [[UILabel alloc] initWithFrame:CGRectMake( eyeImg.bounds.size.width + 23.0 / kAutoWidth , height - 18.0 / kAutoWidth, 40.0 / kAutoWidth, 10.0 / kAutoWidth)];
        _viewCount.text = @"43.9k";
        _viewCount.font = [UIFont systemFontOfSize:12];
        _viewCount.textColor = [UIColor whiteColor];
        [coverImg addSubview:_viewCount];
        
        UIImageView *likeImg = [[UIImageView alloc] initWithFrame:CGRectMake(_viewCount.bounds.size.width + 40.0 / kAutoWidth , height - 20.0 / kAutoWidth,  15.0 / kAutoWidth, 15.0 / kAutoWidth)];
        likeImg.image = [UIImage imageNamed:@"icon_like_white_34"];
        likeImg.layer.masksToBounds = YES;
        
        [coverImg addSubview:likeImg];
        [likeImg release];
        
        _likeCount = [[UILabel alloc] initWithFrame:CGRectMake(likeImg.frame.origin.x + 12.0 / kAutoWidth + 6,  height - 17.0 / kAutoWidth, 40.0 / kAutoWidth, 10.0 / kAutoWidth)];
        _likeCount.textColor = [UIColor whiteColor];
        _likeCount.text = @"770";
        _likeCount.font = [UIFont systemFontOfSize:12];
        [coverImg addSubview:_likeCount];
    }
    return self ;
}

- (void)setCellWithModel:(StrategyModel *)model {
    _title.text = model.title;
    if (model.viewCnt.length > 4) {
        CGFloat viewCount = [model.viewCnt floatValue] / 1000;
        _viewCount.text = [NSString stringWithFormat:@"%.1fk",viewCount];
    }else {
        _viewCount.text = model.viewCnt;
    }
    _likeCount.text = model.likeCnt;
    
    [_imgView sd_setImageWithURL:[NSURL URLWithString:model.coverpic] placeholderImage:nil];
}

@end
